﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProduceBasicData.Api.Application.Command.WarehouseManage;
using ProduceBasicData.Domain.WarehouseManage;
using ProduceBasicData.ErrorCode;

namespace ProduceBasicData.Api.Controllers.WarehouseManage
{
    /// <summary>
    /// 仓库库区控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WarehouseZoneController : ControllerBase
    {
        private readonly IMediator _mediator;

        public WarehouseZoneController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取仓库库区下拉框数据
        /// </summary>
        /// <param name="warehouseId">仓库ID</param>
        /// <returns>仓库库区列表</returns>
        [HttpGet]
        public async Task<ApiResult<List<WarehouseZone>>> GetWarehouseZoneDropdown(int warehouseId)
        {
            GetWarehouseZoneDropdownCommand request = new GetWarehouseZoneDropdownCommand();
            request.WarehouseId = warehouseId;
            return await _mediator.Send(request);
        }
    }
}